<template>
  <el-form ref="form" :model="formData" label-width="120px" inline>
    <el-form-item label="姓名">
      <el-input v-model="formData.name" size="small"></el-input>
    </el-form-item>
    <el-form-item label="年龄">
      <el-input v-model="formData.age" size="small"></el-input>
    </el-form-item>
    <el-form-item label="性别">
      <el-radio v-model="formData.sex" :label="1" size="medium">男</el-radio>
      <el-radio v-model="formData.sex" :label="0" size="medium">女</el-radio>
    </el-form-item>
    <br />
    <el-form-item label="出生日期">
      <el-date-picker v-model="formData.date" type="date" placeholder="请选择日期" value-format="YYYY-MM-DD">
      </el-date-picker>
    </el-form-item>
  </el-form>
</template>

<script>
import { defineComponent, reactive, toRefs } from "vue";
export default {
  props: {
    data: {
      type: Object,
      default: () => ({}),
    },
  },
  setup(props) {
    let formData = reactive({});
    console.log(formData);
    const init = () => {
      props.data && (formData = Object.assign(
        formData,
        JSON.parse(JSON.stringify(props.data))
      ));
      console.log(props.data);
      // 可用打开弹窗后获取数据
      console.log("弹窗打开了");
    };

    return {
      init,
      //
      formData,
    };
  },
};
</script>

<style lang='' scoped>
</style>